from celery import Celery
import os

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')

celery_app = Celery('myproject')
celery_app.config_from_object('django.conf:settings', namespace='CELERY')
celery_app.autodiscover_tasks()

# 配置任务
celery_app.conf.beat_schedule = {
    'change-passwords-every-8-hours': {
        'task': 'myproject.app.tasks.change_root_passwords',
        'schedule': 28800,
    },
    'generate-daily-stats': {
        'task': 'myproject.app.tasks.generate_host_stats',
        'schedule': 86400,
    },
}
